#include<stdio.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<string.h>
#include<sys/types.h>
#include<unistd.h>
#include<stdlib.h>//exit

int main()
{
    umask(0);
    int fd = open("log.txt", O_CREAT | O_WRONLY, 0666);
    if(fd < 0) exit(1);

    printf("%d\n", fd);

    const char *msg = "hello, world!\n";
    int cnt = 5;
    while(cnt)
    {
        write(fd, msg, strlen(msg));
        cnt--;
    }

    close(fd);
//    printf("hello, myfile");

    return 0;
}

